package org.acme.job.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;

import java.util.Date;

@Data
@TableName(value = "sys_job")
public class SysJob extends Model<SysJob> {

    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    @TableField(value = "type")
    private String type;

    @TableField(value = "context")
    private String context;

    @TableField(value = "status")
    private int status;

    @TableField(value = "retry_size")
    private int retrySize;

    @TableField(value = "retry_time")
    private Date retryTime;

    @TableField(value = "server_id")
    private long serverId;

    @TableField(value = "create_time")
    private Date createTime;

    @TableField(value = "update_time")
    private Date updateTime;

    public void recalculateFields(){
        if (this.createTime == null){
            this.createTime = new Date();
        }
        this.updateTime = new Date();
    }
}
